
# 导包
import pymysql


#创还数据库连接


conn = pymysql.connect(host='192.168.121.134',
                       port=3306,
                       user='root',
                       password='123456',
                       database='litemall',
                       charset='utf8'
                       )

# 获取游标对象
cursor = conn.cursor()

# 执行sql
sql = "select version()"
cursor.execute(sql)
# 查看数据库服务器版本
print(cursor.fetchone())

# 关闭游标和数据库连接
cursor.close()
conn.close()
